import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'default-passive-events'

//导入Element-UI-Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

//全局icon图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

//引入Cookie
import Cookies from 'js-cookie'
import {userType} from "./util/base";
let token = Cookies.get("token")
if(token){
    let {user_type} = userType(token);
    let {user_name} = userType(token);
    store.commit('setUserType',user_type)
    store.commit('setUserName',user_name)
    store.commit('setToken',token)
    console.log(store)
}


app.use(store)
app.use(router)
app.use(ElementPlus)
app.mount('#app')
